package com.dyh.scdemo.fconsumer.impor;

import com.dyh.scdemo.fprovider.api.HelloApi;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;

/*
@Author=Joey Wheeler
@Date=2020/10/28 13:11
*/
@Component
@RequestMapping("/ImporHelloApiFallBack")//是这个冲突引起的
/*
不区分会冲突
这是日志打出来的 直接报错了 th [hello fallback]: would dispatch back to the current handler URL [/hello/hello fallback] again.
*/
public  class ImporHelloApiFallBack implements ImporHelloApi{

    @Override
    public String hello(String msg) {
        return "hello fallback";
    }

    @Override
    public String error() {
        return "error fallback";
    }
    /*
    //多次降级
    @HystrixCommand(fallbackMethod = "errorFallback1")
    @Override
    public String error() {
        if (1==1)throw new RuntimeException();
        //这里抛错了再次被降级
        return "error fallback";
    }
    */


    public String errorFallback1(){
        return "error fallback1";
    }

    @Override
    public String timeout(int n) {
        return "timeout fallback";
    }
}
